<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <!--    <link href="__PUBLIC__/uploadify/uploadify.css" rel="stylesheet" type="text/css"/>-->
</head>

<body class="gray-bg">
<style>
    input.error{
        border:1px solid red;
    }
    span.error{
        padding-top:10px;
        color: #f00;
        font-size:12px;
    }
    #video{
        width: 400px !important;
        height: 450px !important;
    }
    .img-box{
        margin-bottom:7px;
        margin-top:5px;
    }
</style>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>创建WIFI码模板</h5>
                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal" id="form">
                        <div class="form-group" id='goodsdiv'>
                            <label class="col-lg control-label">选择商品</label>
                            <div class="col-sm-9 col-xs-12">
                                <div class='form-control-static'>商品名称</div>
                            </div>
                        </div>

                        <div class="form-group">

                            <div class="col-sm-12">
                                <table style='width:100%;'>
                                    <tr>
                                        <td style='width:320px;padding:10px;' valign='top'>
                                            <div id='poster'>
                                                <img src='https://huiyi.opencode.cc/uploads/short_video/20230223/39ca9703e21c201e81176c7f22773b6c.jpeg' class='bg'/>

                                                <div class="drag" type="{$d['type']}" index="{php echo $key+1}" style="zindex:{php echo $key+1};left:{$d['left']};top:{$d['top']};
                             width:{$d['width']};height:{$d['height']}"
                                                     src="{$d['src']}" size="{$d['size']}" color="{$d['color']}"
                                                >
                                                    <img src="../addons/hilike_mall/plugin/poster/static/images/qr.jpg" />
                                                    <img src="../addons/hilike_mall/plugin/poster/static/images/head.jpg" />
                                                    <img src="../addons/hilike_mall/plugin/poster/static/images/img.jpg" />
                                                    <div class=text style="font-size:{$d['size']};color:{$d['color']}">昵称</div>
                                                    <div class=text style="font-size:{$d['size']};color:{$d['color']}">商品名称</div>
                                                    <div class=text style="font-size:{$d['size']};color:{$d['color']}">商品现价</div>
                                                    <div class=text style="font-size:{$d['size']};color:{$d['color']}">商品原价</div>
                                                    <div class="rRightDown"> </div><div class="rLeftDown"> </div><div class="rRightUp"> </div><div class="rLeftUp"> </div><div class="rRight"> </div><div class="rLeft"> </div><div class="rUp"> </div><div class="rDown"></div>
                                                </div>
                                                {/loop}
                                                {/if}
                                            </div>

                                        </td>
                                        <td valign='top' style='padding:10px;'>
                                            <div class='panel panel-default'>
                                                <div class='panel-body'>
                                                    <div class="form-group" id="bgset">
                                                        <label class="col-lg control-label">背景图片</label>
                                                        <div class="col-sm-9 col-xs-12">
                                                            {php echo tpl_form_field_image2('bg',$item['bg'])}
                                                            <span class='help-block'>背景图片尺寸: 640 * 1008</span>
                                                        </div>


                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-lg control-label">海报元素</label>
                                                        <div class="col-sm-9 col-xs-12">
                                                            <button class='btn btn-default btn-com' type='button' data-type='head' >头像</button>
                                                            <button class='btn btn-default btn-com' type='button' data-type='nickname' >昵称</button>
                                                            <button class='btn btn-default btn-com' type='button' data-type='qr' >二维码</button>
                                                            <button class='btn btn-default btn-com' type='button' data-type='img' >图片</button>
                                                            <span id="goodsparams" {if $item['type']!=3}style="display:none"{/if}>
                                                            <br />
                                                            <button class='btn btn-default btn-com' type='button' data-type='title' >商品名称</button>
                                                            <button class='btn btn-default btn-com' type='button' data-type='thumb' >商品图片</button>
                                                            <button class='btn btn-default btn-com' type='button' data-type='marketprice' >商品现价</button>
                                                            <button class='btn btn-default btn-com' type='button' data-type='productprice' >商品原价</button>
                                                            </span>
                                                        </div>
                                                    </div>
                                                    <div id='qrset' style='display:none'>
                                                        <div class="form-group">
                                                            <label class="col-lg control-label">二维码尺寸</label>
                                                            <div class="col-sm-9 col-xs-12">
                                                                <select id='qrsize' class='form-control'>
                                                                    <option value='1'>1</option>
                                                                    <option value='2'>2</option>
                                                                    <option value='3'>3</option>
                                                                    <option value='4'>4</option>
                                                                    <option value='5'>5</option>
                                                                    <option value='6'>6</option>
                                                                </select>
                                                            </div>

                                                        </div>
                                                    </div>

                                                    <div id='nameset' style='display:none'>
                                                        <div class="form-group">
                                                            <label class="col-lg control-label">昵称颜色</label>
                                                            <div class="col-sm-9 col-xs-12">
                                                                <!--{php echo tpl_form_field_color('color')}-->
                                                            </div>

                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-lg control-label">昵称大小</label>
                                                            <div class="col-sm-4">
                                                                <div class='input-group'>
                                                                    <input type="text" id="namesize" class="form-control namesize" placeholder="例如: 14,16"  />
                                                                    <div class='input-group-addon'>px</div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="form-group" id="imgset" style="display:none">
                                                        <label class="col-lg control-label">图片设置</label>
                                                        <div class="col-sm-9 col-xs-12">
                                                            <!--{php echo tpl_form_field_image2('img')}-->
                                                        </div>
                                                    </div>

                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit" id="doSubmit">保存内容</button>
                                <button class="btn btn-primary" type="button" onclick="goBack();">返回</button>
                                <button type="reset" class="btn btn-default">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
<!-- 自定义js -->
<script src="__PUBLIC__/admin/Huploadify/jquery.Huploadify.js"></script>
<script src="__PUBLIC__/admin/js/plugins/layer/layer.min.js"></script>
<script src="__PUBLIC__/admin/js/plugins/validate/jquery.validate.min.js"></script>
<!-- iCheck -->
<script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
<script src="__PUBLIC__/admin/js/common/ajax.js"></script>
<script src="__PUBLIC__/admin/js/common/designer.js"></script>
<script type="text/javascript">

    $('.i-checks').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
    });

    var icon = "<i class='fa fa-times-circle'></i>&nbsp;&nbsp;";
    $('#form').validate({
        errorElement : 'span',
        debug: true,//只验证不提交表单
        //layer ajax提交表单
        submitHandler:function(){
            // 序列化 表单数据 后提交 ，太简洁了
            post("{:url('Video/add')}",'POST',$('#form').serialize(),1);
            return false;
        },//这是关键的语句，配置这个参数后表单不会自动提交，验证通过之后会去调用的方法

        rules:{
            shop_id:{required:true},
            goods_id:{required:true},
            title:{required:true},
            praise_num:{number:true},
            cover_img:{required:true},
            video_path:{required:true},
            describe:{required:true}
        },

        messages:{
            shop_id:{required:icon+'必填'},
            goods_id:{required:icon+'必填'},
            title:{required:icon+'必填'},
            praise_num:{number:icon+'请填写数字'},
            cover_img:{required:icon+'请上传封面图'},
            video_path:{required:icon+'请上传视频'},
            describe:{required:icon+'必填'},
        }
    });

    $('#uploadCoverImage').Huploadify({
        uploader: '{:url("Common/Upload/uploadPic")}',
        method: 'post',
        formData: {name:'short_video'},//发送给服务端的参数，格式：{key1:value1,key2:value2}
        buttonText: '上传封面图',
        removeTimeout: 2000,
        fileTypeDesc: '*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG;',
        fileTypeExts: '*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG;',
        fileObjName: 'file',  //上传附件$_FILE标识
        fileSizeLimit: 2048,
        showUploadedPercent: false,   //是否实时显示上传的百分比，如20%
        auto: true, //开启,自动上传
        multi: false, //开启,多选文件
        //开始上传
        onUploadStart:function(file){
            layer.load(2);
        },
        onUploadSuccess : function(file, data, response) {
            eval('var data='+data);
            if(data.status == 200){
                var res = data.data;
                $('#cover_image').attr('src', res.path);
                $('input[name=cover_img]').val(res.path);
            }else{
                layer.msg(data.mess, {icon: 2,time: 2000});
            }
        },
        //上传完成后执行的操作
        onUploadComplete:function(file){
            layer.closeAll('loading');
        },
        onUploadError : function(file, errorCode, errorMsg, errorString) {
            layer.msg('文件' + file.name + '上传失败:' + errorString, {icon: 2,time: 2000});
        }
    });

    $('#uploadVideo').Huploadify({
        uploader: '{:url("Common/Upload/uploadVideo")}',
        method: 'post',
        formData: {name:'short_video'},
        buttonText: '上传视频',
        removeTimeout: 2000,
        fileTypeDesc:'*.mp4;*.avi;*.rmvb;*.mkv;',
        fileTypeExts:'*.mp4;*.avi;*.rmvb;*.mkv;',
        fileObjName: 'file', //上传附件$_FILE标识
        fileSizeLimit: 31457280,
        showUploadedPercent: false, //是否实时显示上传的百分比，如20%
        auto: true, //开启,自动上传
        multi: false, //开启,多选文件
        //开始上传
        onUploadStart:function(file){
            layer.load(2);
        },
        onUploadSuccess : function(file, data, response) {
            //解析成json对象
            eval('var data='+data);
            if(data.status == 200){
                var res  = data.data;
                $("input[name='video_path']").val(res.path);
                $('#video').attr('src', res.path);
            }else{
                layer.msg(data.mess, {icon: 2,time: 2000});
            }
        },
        //上传完成后执行的操作
        onUploadComplete:function(file){
            layer.closeAll('loading');
        },
        //上传错误
        onUploadError : function(file, errorCode, errorMsg, errorString) {
            layer.msg('文件' + file.name + '上传失败:' + errorString, {icon: 2,time: 2000});
        }
    });

    function selectGoods(){
        var goods_id = $('input[name*=goods_id]').val();
        var shop_id = $("select[name='shop_id']").val();
        var params = '';
        if (goods_id) {
            params += '/goods_id/' + goods_id;
        }
        if (shop_id) {
            params += '/shop_id/' + shop_id;
        }
        var goodsurl = "/{$Request.module}/hdgoods/lst" + params;
        layer.open({
            type: 2,
            title: '选择商品信息',
            shadeClose: true,
            shade: 0.3,
            area: ['70%', '80%'],
            content: goodsurl
        });
    }

    function call_backgoods(goods_id,table_html) {
        layer.closeAll('iframe');
        $('#goods_list').html(table_html);
        if (goods_id == null) {
            layer.msg('请选择商品', {icon: 2, time: 1000});
            return false;
        }

        $('input[name="goods_id"]').val(goods_id);
    }

    function yichu(obj){
        $(obj).parent().parent().remove();
    }

    function removeGoods() {
        $('#goods_list').html('');
    }

    function cl(){
        location.href = "{:url('Video/lst')}";
    }
</script>

</body>
</html>
